package com.tuan.users.pojo;

import java.util.Date;

import org.apache.commons.lang.builder.ReflectionToStringBuilder;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.tuan.common.utils.CommonEnum;

public class Users {
	private static final Log log = LogFactory.getLog(Users.class);
	private Integer id;
	private String username;
	private String email;
	private String password;
	private String web;
	private String ip;
	private Date registTime;
	private CommonEnum.SexEnum sex;
	private CommonEnum.UserStateEnum state;



	public Date getRegistTime() {
		return registTime;
	}

	public void setRegistTime(Date registTime) {
		this.registTime = registTime;
	}

	public String getIp() {
		return ip;
	}

	public void setIp(String ip) {
		if (ip!=null && ip.length() > 16) {
			try {
				this.ip = ip.split(",")[0];
				log.info("init ip: " + ip + " formated ip is " + this.ip
						+ " username: " + this.username);
			} catch (Exception e) {
				log.error("set ip error when insert a user " + ip, e);
			}
		} else {
			this.ip = ip;
		}
	}

	public Integer getId() {
		return id;
	}



	public void setId(Integer id) {
		this.id = id;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getWeb() {
		return web;
	}

	public void setWeb(String web) {
		this.web = web;
	}

	public Users() {

	}

	public Users(Integer id, String username, String password) {
		super();
		this.id = id;
		this.username = username;
		this.password = password;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	@Override
	public String toString() {
		return ReflectionToStringBuilder.toString(this);
	}

	public CommonEnum.SexEnum getSex() {
		return sex;
	}

	public void setSex(CommonEnum.SexEnum sex) {
		this.sex = sex;
	}

	public CommonEnum.UserStateEnum getState() {
		return state;
	}

	public void setState(CommonEnum.UserStateEnum state) {
		this.state = state;
	}
}
